<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of glmgrad</title>
  <meta name="keywords" content="glmgrad">
  <meta name="description" content="GLMGRAD Evaluate gradient of error function for generalized linear model.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; glmgrad.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>glmgrad
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>GLMGRAD Evaluate gradient of error function for generalized linear model.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [g, gdata, gprior] = glmgrad(net, x, t) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">GLMGRAD Evaluate gradient of error function for generalized linear model.

    Description
    G = GLMGRAD(NET, X, T) takes a generalized linear model data
    structure NET  together with a matrix X of input vectors and a matrix
    T of target vectors, and evaluates the gradient G of the error
    function with respect to the network weights. The error function
    corresponds to the choice of output unit activation function. Each
    row of X corresponds to one input vector and each row of T
    corresponds to one target vector.

    [G, GDATA, GPRIOR] = GLMGRAD(NET, X, T) also returns separately  the
    data and prior contributions to the gradient.

    See also
    <a href="glm.html" class="code" title="function net = glm(nin, nout, outfunc, prior, beta)">GLM</a>, <a href="glmpak.html" class="code" title="function w = glmpak(net)">GLMPAK</a>, <a href="glmunpak.html" class="code" title="function net = glmunpak(net, w)">GLMUNPAK</a>, <a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">GLMFWD</a>, <a href="glmerr.html" class="code" title="function [e, edata, eprior, y, a, mse] = glmerr(net, x, t)">GLMERR</a>, <a href="glmtrain.html" class="code" title="function [net, options] = glmtrain(net, options, x, t)">GLMTRAIN</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>	CONSIST Check that arguments are consistent.</li><li><a href="gbayes.html" class="code" title="function [g, gdata, gprior] = gbayes(net, gdata)">gbayes</a>	GBAYES	Evaluate gradient of Bayesian error function for network.</li><li><a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">glmfwd</a>	GLMFWD	Forward propagation through generalized linear model.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="glmtrain.html" class="code" title="function [net, options] = glmtrain(net, options, x, t)">glmtrain</a>	GLMTRAIN Specialised training of generalized linear model</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [g, gdata, gprior] = glmgrad(net, x, t)</a>
0002 <span class="comment">%GLMGRAD Evaluate gradient of error function for generalized linear model.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%    Description</span>
0005 <span class="comment">%    G = GLMGRAD(NET, X, T) takes a generalized linear model data</span>
0006 <span class="comment">%    structure NET  together with a matrix X of input vectors and a matrix</span>
0007 <span class="comment">%    T of target vectors, and evaluates the gradient G of the error</span>
0008 <span class="comment">%    function with respect to the network weights. The error function</span>
0009 <span class="comment">%    corresponds to the choice of output unit activation function. Each</span>
0010 <span class="comment">%    row of X corresponds to one input vector and each row of T</span>
0011 <span class="comment">%    corresponds to one target vector.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%    [G, GDATA, GPRIOR] = GLMGRAD(NET, X, T) also returns separately  the</span>
0014 <span class="comment">%    data and prior contributions to the gradient.</span>
0015 <span class="comment">%</span>
0016 <span class="comment">%    See also</span>
0017 <span class="comment">%    GLM, GLMPAK, GLMUNPAK, GLMFWD, GLMERR, GLMTRAIN</span>
0018 <span class="comment">%</span>
0019 
0020 <span class="comment">%    Copyright (c) Ian T Nabney (1996-2001)</span>
0021 
0022 <span class="comment">% Check arguments for consistency</span>
0023 errstring = <a href="consist.html" class="code" title="function errstring = consist(model, type, inputs, outputs)">consist</a>(net, <span class="string">'glm'</span>, x, t);
0024 <span class="keyword">if</span> ~isempty(errstring);
0025   error(errstring);
0026 <span class="keyword">end</span>
0027 
0028 y = <a href="glmfwd.html" class="code" title="function [y, a] = glmfwd(net, x)">glmfwd</a>(net, x);
0029 delout = y - t;
0030 
0031 gw1 = x'*delout;
0032 gb1 = sum(delout, 1);
0033 
0034 gdata = [gw1(:)', gb1];
0035 
0036 [g, gdata, gprior] = <a href="gbayes.html" class="code" title="function [g, gdata, gprior] = gbayes(net, gdata)">gbayes</a>(net, gdata);</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>